﻿using System;
using System.Collections.Generic;

using NMemcached.Client.Configuration;

namespace NMemcached.Client
{
    /// <summary>
    /// Defines the elements required to provide memcached server connections
    /// </summary>
    public interface IConnectionProvider : IDisposable
    {
        /// <summary>
        /// Gets a collection of available servers
        /// </summary>
        IEnumerable<ServerConnection> Servers { get; }

        /// <summary>
        /// Gets a collection of unavailable servers
        /// </summary>
        IEnumerable<ServerConnection> Unavailable { get; }

        /// <summary>
        /// Closes all server connections
        /// </summary>
        void Close();

        /// <summary>
        /// Gets a server connection for the specified key
        /// </summary>
        /// <param name="key">The key of the cache entry</param>
        /// <returns>A server connection for the specified key</returns>
        ServerConnection GetConnection(string key);

        /// <summary>
        /// Gets the server connection for the specified keys
        /// </summary>
        /// <param name="keys">The keys of the cache entries</param>
        /// <returns>A dictionary of server connection to cache key mappings</returns>
        IDictionary<ServerConnection, List<string>> GetConnections(params string[] keys);

        /// <summary>
        /// Removes a connection from the list of available servers
        /// </summary>
        /// <param name="connection">The connection to remove</param>
        [Obsolete("This method was deprecated in version 1.1 and will not be available in future versions.", false)]
        void MarkDown(ServerConnection connection);

        /// <summary>
        /// Removes a connection from the list of available servers
        /// </summary>
        /// <param name="connection">The connection to remove</param>
        void DisableConnection(ServerConnection connection);
    }
}